﻿#pragma once


#include "MaterialGraph/Node/MaterialGraphNodeModel.h"
#include "MaterialFloatNodeModel.m.h"

RCLASS(ExtraHeader = "MaterialGraph/Pin/MaterialGraphPinModel.h")
class RMaterialFloatNodeModel : public RMaterialGraphNodeModel
{
    ROBJECT
    
public:
    virtual void FirstTimeInitializeObject() override;

    virtual CString GenerateExpression() override;

    RFIELD()
    float Value = 0.0f;

   
    void SetIsParameter(bool InIsParameter);
    TDelegate<void> OnIsParameterChanged;
protected:
    //是否是参数,参数是可以在运行时修改的
    RFIELD()
    bool bIsParameter = false;

public:
    //能不能转换成参数
    virtual bool CanConvertToParameter() const override { return !bIsParameter; }
    //能不能改出参数
    virtual bool CanConvertFromParameter() const override{ return bIsParameter; }
    //是不是参数节点
    virtual bool IsParameter() const override{ return bIsParameter; }
    //获取参数名字
    virtual CString GetParameterName() const override{ return ParameterName; }
    //设置参数名字
    virtual void SetParameterName(const CString& InName) override{ ParameterName=InName;}

    //参数名,如果是参数的话,这个参数名会在材质编辑器中显示
    //在运行时可以通过这个名字修改参数
    RFIELD()
    CString ParameterName;

    virtual void CollectParameterAndTextures(
        TVector<float>& InOutFloatParameters 
        ,TVector<TSharedObjectPtr<RTexture2D>>& InOutTexture2Ds
        ,TMap<CString,SMaterialParameterDescription>& InOutParameterDescriptions
    ) override;

protected:
    //参数在浮点参数数组中的偏移
    //在编译时设置
    uint64_t FloatParameterOffset = 0;

};